﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class ChangePwd : System.Web.UI.Page
{
    User userSrv = new User();
    MyDataDataContext db = new MyDataDataContext();
    protected void Page_Load(object sender, EventArgs e)
    {

        if (Session["UserId"] == null)  //用户未登录
        {
            Response.Redirect("~/Login.aspx");
        }
    }
    protected void BtnChangePwd_Click(object sender, EventArgs e)
    {
       User user = (from c in db.User
                             where c.UserID== txtOldPwd.Text
                    select c).First();
        
        
            if (user.UserPwd == txtPwd.Text)
            {
                user.UserPwd = txtOldPwd.Text;
                db.SubmitChanges();
                
                lblMsg.Text = "密码修改成功！";
            }
            else  //输入的原密码不正确
            {
                lblMsg.Text = "原密码不正确！";
            }
        
    }
}